var levelOrderBottom = function (root) {
  if (!root) return [];
  let queue = [root],
      res = [];
  while (queue.length) {
    let len = queue.length;
    let level = [];
    while (len--) {
      let cur = queue.shift();
      level.push(cur.val);
      if (cur.left) queue.push(cur.left);
      if (cur.right) queue.push(cur.right);
    }
    res.unshift(level);
  }
  return res;
}